//
//  UIView+Extension.swift
//  Faner_Weibo
//
//  Created by 范英强 on 16/1/21.
//  Copyright © 2016年 范英强. All rights reserved.
//

import UIKit
// @IBInspectable 用于其他的属性可以在xib右侧面板显示
// @IBDesignable 动态渲染view
extension UIView{
    /// cornerRadius
    
    @IBInspectable var cornerRadius:CGFloat {
        get{
            return layer.cornerRadius
        }
        set{
            layer.cornerRadius = newValue
            layer.masksToBounds = cornerRadius > 0
        }
    }
    
    /// cornerRadius
    @IBInspectable var borderColor:UIColor? {
        get{
            guard let c = layer.borderColor else {
                return nil
            }
            
            return UIColor(CGColor: c)
        }
        set{
            layer.borderColor = newValue?.CGColor
        }
    }
    
    /// cornerRadius
    @IBInspectable var borderWidth:CGFloat {
        get{
            return layer.borderWidth
        }
        set{
            layer.borderWidth = newValue
        }
    }
    
    
}
